package com.lollipop.synthential.java8.lambda.syntax.Exercise;

import com.lollipop.synthential.java8.lambda.syntax.data.Person;

import java.util.TreeSet;

/**
 * @Author: J.K
 * @Date: 2021-02-15 21:46
 * @Description:
 */
public class Excise2 {
    public static void main(String[] args) {

        TreeSet<Person> set = new TreeSet<>((o1, o2) -> {
            // 修改逻辑，防止set去重
            if (o1.age >= o2.age) {
                return -1;
            } else {
                return 1;
            }
        });

        set.add(new Person("小明", 10));
        set.add(new Person("小蓝", 12));
        set.add(new Person("小红", 8));
        set.add(new Person("小黄", 16));
        set.add(new Person("小绿", 6));
        set.add(new Person("小黑", 6));

        System.out.println(set);

    }
}
